<template>
    <div>
        <div class="mui-numbox" data-numbox-min='1' style="height:30px">
            <!-- "-"按钮，点击可减小当前数值 -->
            <button class="mui-btn mui-numbox-btn-minus" type="button" >-</button>
            <input class="mui-numbox-input" type="number" :value="initcount" ref="nobox" @change="countChange"/>
            <!-- "+"按钮，点击可增大当前数值 -->
            <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
        </div>
    </div>
</template>

<script>
import mui from "../../../lib/mui/js/mui.js"
import {mapMutations} from "vuex"


export default {
    data() {
        return {
         
        }
    },
    methods:{
        countChange(){
            //获取商品数量
            const val = parseInt(this.$refs.nobox.value);
            //更新数量
            this.updateGoodsCount({id:this.id,count:val})
            
        },
        ...mapMutations(["updateGoodsCount"])
    },
    mounted(){
        //初始化numbox
        mui(".mui-numbox").numbox()

    },
    props:["initcount","id"],

}
</script>

<style lang="scss" scoped>
    
</style>